﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.SoldierArchives.Model;
using Yipusoft.SoldierArchives.BLL;

public partial class BasicBase_SoldierArchive_SoldierResult : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewState["SR"] = Request.UrlReferrer.ToString();
            init();
        }
    }

    void init()
    {
        if (Request["Where"] != null)
        {
            ListPageContral1.SetFirstPage();
            BindGV(0);
        }
    }

    void BindGV(int pageIndex)
    {
        string Where = Request.QueryString["Where"];
        NewSoldier soldier = new NewSoldier();
        ListPageContral1.ItemCount = soldier.GetSoldiersCountByWhere(Where);
        List<SoldierArchiveInfo> list = new List<SoldierArchiveInfo>();

        list = soldier.GetSoldiersByWhere(Where, orderKey.SelectedValue, "Asc", ListPageContral1.PageSize, pageIndex);
        gvSoldiers.DataSource = list;
        gvSoldiers.DataBind();
    }

    protected void ListPageContral1_PageSizeChange(int pageSize, int PageIndex)
    {
        BindGV(PageIndex);
    }
    protected void gvSoldiers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label ID = (Label)e.Row.FindControl("ID");
            ID.Text = Convert.ToString(gvSoldiers.PageSize * ListPageContral1.CurrentPageIndex + (e.Row.RowIndex + 1));
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }
    }
    protected void gvSoldiers_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    protected void orderKey_SelectedIndexChanged(object sender, EventArgs e)
    {
        init();
    }
    protected void lkbReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect(ViewState["SR"].ToString());
    }
}
